package demo7;

import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

@Component
public class Person implements InitializingBean, DisposableBean {
    private String name;
    private int age;

    public Person() {
        System.out.println("1:Person的构造器被调用了");
    }

    public int getAge() {
        return age;
    }
    @Value("18")
    public void setAge(int age) {
        System.out.println("2:Person的setAge方法被调用了");
        this.age = age;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
    public void sayHello(){
        System.out.println("4:Person的成员方法sayHello被调用了");
    }

    @Override
    public void destroy() throws Exception {

    }

    @Override
    public void afterPropertiesSet() throws Exception {

    }
}
